import {
  reqGetResumeList,
  reqBatchAddResume,
  reqEditResume,
  reqBatchDelResume,
  reqGetResumeById,
} from '@/views/Custom/ResumeMng/api/ResumeMngApi';
const actions = {
  // 获取简历列表
  async getResumeList({ commit }, params) {
    let result = await reqGetResumeList(params);
    commit('GETRESUMELIST', result.data.resumeIPage);
  },
  //简历信息新增
  async batchAddResume({ commit }, params) {
    let result = await reqBatchAddResume(params);
    return result;
  },
  //简历编辑
  async editResume({ commit }, params) {
    let result = await reqEditResume(params);
    return result;
  },
  //简历删除
  async delResume({ commit }, params) {
    let result = await reqBatchDelResume(params);
    return result;
  },
  // 根据编号查询简历信息
  async getResumeById({ commit }, params) {
    let result = await reqGetResumeById(params);
    commit('GETRESUMEBYID', result.data.resumeInfo);
    return result;
  },
};
const mutations = {
  // 获取简历列表
  GETRESUMELIST(state, result) {
    state.resumeIPage = result;
  },
  // 根据编号查询简历信息
  GETRESUMEBYID(state, result) {
    state.resumeInfo = result;
  },
};
const state = {
  resumeInfo: {},
  resumeIPage: {}, //简历分页查询后返回的对象
  resumeList: {}, //简历分页查询后返回的对象
};
const getters = {
  resumeIPage(state) {
    return state.resumeIPage || [];
  },
  resumeList(state) {
    return state.resumeIPage ? state.resumeIPage.records || [] : [];
  },
  resumeInfo(state) {
    return state.resumeInfo || {};
  },
};
export default {
  namespaced: true,
  actions,
  mutations,
  state,
  getters,
};
